<?php

namespace App\Http\Controllers\OpenShop\SiteLocation;

use App\Enums\OpenShop\BaseEnum;
use App\Http\Controllers\BaseController;
use App\Service\Common\HolidayService;
use App\Service\Common\WeatherService;
use Illuminate\Http\Request;

class WeatherController extends BaseController
{
    public function getWeatherHoliday(Request $request)
    {
        $this->validate($request, [
            'area' => 'string'
        ]);
        $area = $request->get('area', '');
        $weekDay = (int)(date('w') ?: 7);
        $data = [
            [
                'field' => 'time',
                'text'  => date('Y-m-d'),
            ],[
                'field' => 'week',
                'text'  => BaseEnum::WEEK_MAPPING[$weekDay] ?? '-',
            ],[
                'field' => 'dateType',
                'text'  => HolidayService::getHolidayByDay(),
            ]
        ];
        return $this->success(array_merge($data, WeatherService::getWeatherByArea($area)));
    }

}
